% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/frs_update_datasets.R
\name{frs_update_datasets}
\alias{frs_update_datasets}
\title{Main function that updates several FRS datasets for use in EJAM}
\usage{
frs_update_datasets(
  folder = NULL,
  folder_save_as_arrow = ".",
  downloaded_and_unzipped_already = FALSE,
  csvname = "NATIONAL_SINGLE.CSV",
  save_as_arrow_frs = TRUE,
  save_as_arrow_frs_by_programid = TRUE,
  save_as_arrow_frs_by_naics = TRUE,
  save_as_arrow_frs_by_sic = TRUE,
  save_as_arrow_frs_by_mact = TRUE,
  save_as_data_frs = FALSE,
  save_as_data_frs_by_programid = FALSE,
  save_as_data_frs_by_naics = FALSE,
  save_as_data_frs_by_sic = FALSE,
  save_as_data_frs_by_mact = FALSE
)
}
\arguments{
\item{folder}{optional folder for where to download to; uses temp folder by default}

\item{folder_save_as_arrow}{optional folder where to save any .arrow files}

\item{downloaded_and_unzipped_already}{optional, set to TRUE if already downloaded latest
and folder will be specified or can be assumed to be current working directory}

\item{csvname}{optional, passed to frs_get()}

\item{save_as_arrow_frs}{Whether to save as .arrow in getwd()}

\item{save_as_arrow_frs_by_programid}{Whether to save as .arrow in getwd()}

\item{save_as_arrow_frs_by_naics}{Whether to save as .arrow in getwd()}

\item{save_as_arrow_frs_by_sic}{Whether to save as .arrow in getwd()}

\item{save_as_arrow_frs_by_mact}{Whether to save as .arrow in getwd()}

\item{save_as_data_frs}{Whether to save as .rda in ./data/}

\item{save_as_data_frs_by_programid}{Whether to save as .rda in ./data/}

\item{save_as_data_frs_by_naics}{Whether to save as .rda in ./data/}

\item{save_as_data_frs_by_sic}{Whether to save as .rda in ./data/}

\item{save_as_data_frs_by_mact}{Whether to save as .rda in ./data/}
}
\value{
Creates saved copies of datasets for the R package, overwriting old ones, using
\code{\link[=frs_get]{frs_get()}} and \code{\link[=frs_inactive_ids]{frs_inactive_ids()}} and other functions, and invisibly returns \link{frs}.
}
\description{
Main function that updates several FRS datasets for use in EJAM
}
\details{
This takes several minutes to download and clean data files,
and is used by someone maintaining the EJAM package, to obtain updated
Facility Registry Service (FRS) data on EPA-regulated sites.

This function is only for a package maintainer/updater or to update a local copy.
It would normally be called from a script like
EJAM/data-raw/datacreate_0_UPDATE_ALL_DATASETS.R

These datasets have been stored in a pins board, not as part of the package,
so the save_as_data_ parameters here are set to FALSE. The updated files can be
moved to the pins board via the script.

To update the datasets for the R package using local source code,
use frs_update_datasets(), in conjunction with the EJAM package.

For example to read back in a saved file,

\if{html}{\out{<div class="sourceCode">}}\preformatted{frs <- arrow::read_ipc_file(file = file.path(folder_save_as_arrow, "frs.arrow"))
}\if{html}{\out{</div>}}

Or, more generally,

to assign to default, current environment:

varname <- "frs"

fold <- folder_save_as_arrow # e.g., fold <- getwd()

fname <- paste0(varname, ".arrow")

assign(varname, value = arrow::read_ipc_file(file = file.path(fold, fname)))
}
\seealso{
\code{\link[=frs_get]{frs_get()}} \code{\link[=frs_inactive_ids]{frs_inactive_ids()}} \code{\link[=frs_drop_inactive]{frs_drop_inactive()}}
\code{\link[=frs_make_programid_lookup]{frs_make_programid_lookup()}} \code{\link[=frs_make_naics_lookup]{frs_make_naics_lookup()}} \code{\link[=frs_make_sic_lookup]{frs_make_sic_lookup()}} \code{\link[=frs_make_mact_lookup]{frs_make_mact_lookup()}}
}
